import {DECRNMENT, INCRNMENT} from "./mutations-type";
import Vue from "vue";

export default {
  // 传入变量的方式命名方法 mutations推荐用变量命名
  [INCRNMENT](state) {
    state.counter++;
  },
  [DECRNMENT](state) {
    state.counter--;
  },
  // incrnment(state) {
  //   state.counter++;
  // },
  // decrnment(state) {
  //   state.counter--;
  // },
  incrnmentCount(state, count) { // 接收count参数
    console.log(count);
    // state.counter += count
    // 特殊提交的封装是以对象形式提交
    state.counter += count.count
  },
  addStudent(state, student) {
    state.students.push(student)
  },
  updateInfo(state) {
    // state.info.name = "456";

    // 单独操作不能响应式
    // state.info['address'] = "四川"
    // Vue.set(state.info, "address", "四川")

    // 单独操作不能响应式
    // delete state.info.age
    Vue.delete(state.info, "age")
  }
}
